import axios, { type AxiosInstance, type CreateAxiosDefaults } from 'axios'
import { setupInterceptors } from './interceptors'

export function createAxios(options: CreateAxiosDefaults = {}): AxiosInstance {
  const defaultOptions: CreateAxiosDefaults = {
    baseURL: import.meta.env.VITE_AXIOS_BASE_URL as string,
    timeout: 12000
  }
  const service = axios.create({
    ...defaultOptions,
    ...options
  })
  setupInterceptors(service)
  return service
}

export const request = createAxios()

// 移除 mockRequest，因为 MSW 会直接拦截请求，不需要单独的实例
